package com.zr.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.RoleDao;
import com.zr.model.TRole;

import net.sf.json.JSONArray;

@Repository("roleDao")
public class RoleDaoImpl<T> extends  BaseDaOImpl<T> implements RoleDao<T> {
	Map<String, String> role =  new HashMap<String, String>();
	@Override
	public JSONArray getRole() {
		// TODO Auto-generated method stub
		JSONArray jsa=new JSONArray();
		String hql="from TRole";
		Query query=this.getCurrentSession().createQuery(hql);
		List<TRole> roles=query.list();
		for (TRole tRole : roles) {
			String rid=String.valueOf(tRole.getRid());
			String rname=tRole.getRname();
			role.put("id", rid);
			role.put("text", rname);
			jsa.add(role);
		}
		return jsa;
	}
}
